﻿using System;
using System.Collections.Generic;

namespace AppMain
{

    public interface IEvent
    {
        int LockStatus
        {
            get;
        }
        int EventType
        {
            get;
        }

        float Progress
        {
            get;
        }

        BaseAction Action { get; set; }

        void processEvent();
        void enter();
        void exit();
        void dispose();
    }

    public class BaseEvent<U> : IEvent where U : BaseEventData, new()
    {
        protected U m_data;

        private int lockStatus = 0;
        public int LockStatus => this.lockStatus;

        public int EventType => this.m_data.eventType;

        private float progress = 0;
        public float Progress => this.progress;

        private BaseAction action;
        public BaseAction Action
        {
            get => this.action;
            set
            {
                this.action = value;
                this.progress = this.m_data.startTime / this.action.totalTime;
            }
        }

        private Action_Status Status = Action_Status.Wait;

        public void dispose()
        {

        }

        public void enter()
        {
            onEnter();
        }

        public void exit()
        {
            onExit();
        }

        public void processEvent()
        {
            if (this.Status == Action_Status.Finish) return;
            onProcess();
            this.Status = Action_Status.Finish;
        }

        protected virtual void onProcess()
        {

        }

        protected virtual void onEnter()
        {

        }
        protected virtual void onExit()
        {

        }

        public void setData(U data)
        {
            this.m_data = data;
        }

    }

}
